package com.edu.converter;

import com.edu.bean.User;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


public class MyStringToUserConverter implements Converter<String, User> {
    @Override
    public User convert(String source) {
        //具体的转换规则
        System.out.println("执行了类型转换器");
        System.out.println(source);
        String[] strings = source.split("-");
        String username = strings[0];
        String password = strings[1];
        int age = Integer.parseInt(strings[2]);
        User user = new User(username,password,age);
        return user;
    }
}
